package ru.compft.media.example;

import javax.media.*;
import javax.media.protocol.ContentDescriptor;
import javax.media.protocol.DataSource;
import javax.media.protocol.FileTypeDescriptor;
import java.io.IOException;

/**
 * User: ASUS
 * Date: 01.09.12
 * Time: 13:31
 */
public class SimpleMediaPlayer {

    private static MediaLocator mediaLocator = null;
    private static DataSink dataSink = null;
    private static Processor mediaProcessor = null;
    private static final Format[] FORMATS = new Format[0];//{
    //new AudioFormat(AudioFormat.MPEG_RTP)};
    private static final ContentDescriptor CONTENT_DESCRIPTOR =
            new ContentDescriptor(ContentDescriptor.RAW_RTP);
    private static Player player;

    public static void main(String[] args){
        try {
        DataSource ds = Manager.createDataSource(new MediaLocator("vfw:Microsoft WDM Image Capture (Win32):0"));
        mediaProcessor = Manager.createRealizedProcessor(new ProcessorModel(ds, FORMATS, CONTENT_DESCRIPTOR));
        dataSink = Manager.createDataSink(mediaProcessor.getDataOutput(), mediaLocator);

//        Processor ip = Manager.createRealizedProcessor(new MediaLocator("vfw://0"));
//        ip.setContentDescriptor(new FileTypeDescriptor(FileTypeDescriptor.QUICKTIME));


//            player = Manager.createRealizedPlayer(ip.getDataOutput());
//            player.start();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}
